<html>
<head>
<title>Register</title>
</head>
<body>
<center>
<?php
	include "dbconnect.php";
	$fName=$_POST["fname"];
	$lName=$_POST["lname"];
	$email=$_POST["email"];
	$pass=$_POST["password"];
	$sql = "SELECT * FROM student WHERE email='$email'";
	$result = mysql_query($sql);
	if(mysql_num_rows($result) > 0) 
		echo 'The username already exists ';

	$query=mysql_query("insert into student(fname,lname,email,password) values('$fName','$lName','$email','$pass')");
	if($query) {
 		echo "<h1>Successfully registered</h1><br /><br />";
	}
	else
	{
		echo mysql_error();
	}
	echo " <b>Redirecting back in 2 seconds...</b>";
	header("refresh:2;url=index.php");
?>
</center>
</body>
</html>